package com.kuang.array;

import java.util.Arrays;
import java.util.List;

/**
 * @author wuJiaWei
 * @version 1.0
 * @date 2024/8/10
 * @time 11:36:43
 */
public class Demo06 {
    public static void main(String[] args) {
        int[] arr = {15,1, 2, 3, 4, 5};
        search(arr);
        System.exit(0);

        int[] nums = new int[10];
        Arrays.fill(nums, 0, 10, 1);//填充,从0开始，填充10个1
        System.out.println(Arrays.toString(nums));

        System.out.println(arr);//[I@4554617c
        System.out.println(Arrays.toString(arr));
        printArray(arr);

        Arrays.sort(arr);//排序
        System.out.println(Arrays.toString(arr));

    }

    public static void search(int[] arr){
        int a = Arrays.binarySearch(arr, 1);//二分查找
        System.out.println(a);
    }
    public static void printArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            if (i==0){
                System.out.print('[');
            }
            if (i== arr.length-1){
                System.out.print(arr[i] + "]");
            }else {
                System.out.print(arr[i] + ",");
            }
        }
    }
}
